﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Sol001 {

   public int[] Twonums(int[] nums,int target)
    {
        Dictionary<int, int> map = new();//val,i
        int[] res = new int[2];

        for (int i = 0; i < nums.Length; i++) {


            if (map.ContainsKey(target-nums[i]))
            {

                res[1] = i;//这是后面的数字
                res[0]=map[target-nums[i]];
                break;

            }
            else//另一个数字没有遇到的时候，先入队
            {

                map[nums[i]] = i;

            }
        
        }


        return res;

    }


}
class Program001
{

    static void Main001(string[] args)
    {
        int[] nums = { 2, 7, 11, 15 };

        int target = 9;
        Sol001 sol= new Sol001();
      int[] res=  sol.Twonums(nums, target);

        for (int i = 0; i < 2; i++) {
            Console.WriteLine(res[i]);
        }
    }
    }

